package day03;

import java.util.Scanner;

//1. 猜数字
//生成一个1 ~ 100 随机整数
//让玩家在控制台猜这个数是多少
//如果猜大了或猜小了, 给出相应提示
//猜中后显示玩家共猜了几次
public class Homework01 {
	public static void main(String[] args) {

		int min = 1, max = 100;
		int ran = (int) (Math.random() * (max - min + 1) + min);
		System.out.println("随机数已产生, 猜猜是多少");

		Scanner sc = new Scanner(System.in);

		int count = 0;

		while (true) {
			int i = sc.nextInt();
			count++;

			if (i == ran) {
				break;
			}

			if (i < ran) {
				System.out.println("猜小了");
				continue;
			}

			System.out.println("猜大了");

		}

		System.out.println("你猜中了, 你猜了" + count + "次");

	}
}
